home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: mxsld2.pd.infn.it!LORETI
- From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
- Subject: Re: Finding a prime number
- X-Nntp-Posting-Host: mxsld2.pd.infn.it
- Message-ID: <DLy7y5.B0z@news.cern.ch>
- Sender: news@news.cern.ch (USENET News System)
- Reply-To: loreti@mxsld2.pd.infn.it
- Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
- References: <4e875s$nqk@reader2.ix.netcom.com>,<4eb8lo$9rf@news1.cle.ab.com>
- Distribution: inet
- Date: Mon, 29 Jan 1996 15:20:26 GMT
-
- In article <4eb8lo$9rf@news1.cle.ab.com>, don.phillips@ab.com (Donald-Anthony C. Phillips) writes:
- > It seems your algorithm may not be mathematically correct. Your
- >assumption( if i'm reading your code right) is that if a number is not
- >divisible evenly by any of the numbers 0-9, then it must be prime.
- >This is not correct.
- > Take for instance the number 247. It is not divisible by 0-9 but it
- >is not a prime number( 13*19 = 247). The definition of a prime number
- >is a number divisible only by one and the number.
- > Most prime number algorithms will be iterative or recursive by nature.
- >A number (n) is prime if is not divisible by any number from 2 thru
- >(n - 1).....roughly.
-
- You misspelled floor(sqrt(n)).
- --
- Maurizio Loreti http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
- Un. of Padova, Dept. of Physics - Padova, Italy loreti@padova.infn.it
-